//package com.yomahub.liteflow.example.config;
//
//import cn.hutool.core.io.IoUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.sza.qar.decoder.misc.BeansParser;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//
////@Component
//public class BaseDecodeConfig implements CommandLineRunner {
//    @Value("${spring.profiles.active}")
//    private String active;
//
//    @Value("${base-decode-beans-path}")
//    private String beanxml;
//
//    public void setBeansParser() {
//        String xmlPath = "";
//        if (StrUtil.equals("prod", active)) {
//            xmlPath = "config/prod.components.beans.xml";
//        } else if (StrUtil.equals("test", active)) {
//            xmlPath = "config/test.components.beans.xml";
//        } else {
//            xmlPath = "config/dev.components.beans.xml";
//        }
//        ClassPathResource resource = new ClassPathResource(xmlPath);
//
//        File file = new File(beanxml, "basedecodebeans.xml");
//        try (InputStream inputStream = resource.getInputStream();
//             FileOutputStream fileOutputStream = new FileOutputStream(file)) {
//            IoUtil.copy(inputStream, fileOutputStream);
//            String absolutePath = file.getAbsolutePath();
//            new BeansParser(absolutePath);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public void run(String... args) throws Exception {
//        setBeansParser();
//    }
//}